<?php

require "include/bittorrent.php";
dbconn();
loggedinorreturn();
if ($CURUSER['class'] < UC_USER)
	stderr("错误", "等级不足");
$HTMLOUT = "";
$HTMLOUT .="<a href='bet.php'><img src='betting.png' alt='Bet' title='博彩' width='400' height='125' /></a>
<h1>博彩频道</h1>
<table class='main' cellspacing='0' cellpadding='5' border='0'>
<tr>
<td align='center' class='navigations'><a href='bet.php'>当前竞猜</font></a></td>
<td align='center' class='navigations'><a href='bet_old.php'>闭盘竞猜</a></td>";
if ($CURUSER['class'] >= UC_MODERATOR || $CURUSER['id'] == $betsadmin) {
	$HTMLOUT .= "<td align='center' class='navigations'><a href='bet_admin.php'>管理竞猜</a></td>";
}
$HTMLOUT .="<td align='center' class='navigations'><a href='bet_coupon.php'><font color='red'>我的押注</a></td>
<td align='center' class='navigations'><a href='bet_bonustop.php'>用户排名</a></td>
<td align='center' class='navigations'><a href='bet_info.php'>系统帮助</a></td>
</tr></table><br />";
$main = sql_query("SELECT * FROM bets WHERE userid = " . sqlesc($CURUSER['id']) . "") or sqlerr(__FILE__, __LINE__);
$HTMLOUT .="<table cellpadding='5'>
<tr>
<td colspan='1' class='colhead'>标题</td>
<td colspan='1' class='colhead'>押注选项</td>
<td colspan='1' class='colhead'>倍率</td>
<td colspan='1' class='colhead'>押注金额</td>
<td colspan='1' class='colhead'>可获金额</td>
</tr>";
if (mysql_num_rows($main) == 0) {
	$HTMLOUT .="<tr><td  colspan='5'><i>你还没有参加</i></tr>";
}
while ($more = mysql_fetch_assoc($main)) {
	$id = $more['optionid'];
	$res = sql_query("SELECT * FROM betoptions WHERE id =" . sqlesc($id) . "") or sqlerr(__FILE__, __LINE__);
	$a = mysql_fetch_array($res);
	$res2 = sql_query("SELECT * FROM betgames WHERE id = " . sqlesc($a['gameid']) . "") or sqlerr(__FILE__, __LINE__);
	$b = mysql_fetch_array($res2);
	$odds = $a['odds'];
	$HTMLOUT .="<tr><td>{$b['heading']}</td><td>{$a['text']}</td><td>{$odds}</td><td class='noflagclear' align='right'>{$more['bonus']}</td><td class='noflagclear' align='right'><b>" . round(($more['bonus'] * $a['odds']) * 0.95) . "</b></td></tr>";
}
$HTMLOUT .="</table>";
stdhead('博彩');
print $HTMLOUT;
stdfoot();
